<cfcomponent accessors="true">

	
	<cfproperty name="files" type="struct" />
	<cfproperty name="defaultKeyStartFormat" type="string" />
	<cfproperty name="defaultKeyEndFormat" type="string" />
	<cfproperty name="smartUpdate" type="boolean" />
	
	
	<cffunction name="init" access="public" returntype="any">
		<cfargument name="defaultKeyStartFormat" type="string" required="no" default="" />
		<cfargument name="defaultKeyEndFormat" type="string" required="no" default="" />
		<cfargument name="smartUpdate" type="boolean" required="no" default="true" />
		<cfscript>
			setFiles(StructNew());
			setDefaultKeyStartFormat(arguments.defaultKeyStartFormat);
			setDefaultKeyEndFormat(arguments.defaultKeyEndFormat);
			setSmartUpdate(arguments.smartUpdate);
			return this;
		</cfscript>
	</cffunction>
	
	
	<cffunction name="addFile" access="public" returntype="any">
		<cfargument name="name" type="string" required="yes" />
		<cfargument name="path" type="string" required="yes" />
		<cfargument name="defaultKeyStartFormat" type="string" required="no" default="#getDefaultKeyStartFormat()#" />
		<cfargument name="defaultKeyEndFormat" type="string" required="no" default="#getDefaultKeyEndFormat()#" />	
		<cfargument name="smartUpdate" type="boolean" required="no" default="#getSmartUpdate()#" />	
		<cfscript>
			local.oFile = CreateObject("component","FileSegmentManager.File").init(
				name = arguments.name,
				path = arguments.path,
				defaultKeyStartFormat = arguments.defaultKeyStartFormat,
				defaultKeyEndFormat = arguments.defaultKeyEndFormat,
				smartUpdate = arguments.smartUpdate
			);
			StructInsert(getFiles(), arguments.name, local.oFile);
			return this;
		</cfscript>
	</cffunction>
	
	
	<cffunction name="getFile" access="public" returntype="any">
		<cfargument name="name" type="string" required="yes" />
		<cfreturn getFiles()[arguments.name] />
	</cffunction>
	
	
	<cffunction name="processAll" access="public" returntype="any">
		<cfscript>
			local.files = getFiles();
			local.keyList = StructKeyList(local.files);
			for (local.i=1;local.i LTE ListLen(local.keyList);local.i++) {
				local.files[ListGetAt(local.keyList,i)].process();
			}
		</cfscript>
	</cffunction>
	
	
</cfcomponent>